//
//  WBWelComeController.swift
//  weibo
//
//  Created by Felix on 16/11/15.
//  Copyright © 2016年 Felix. All rights reserved.
//

import UIKit
import SDWebImage

class WBWelComeController: UIViewController {
    @IBOutlet var avatarImageView: UIImageView!

    @IBOutlet var avatarBottomCons: NSLayoutConstraint!
    @IBOutlet var welComeLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        avatarImageView.layer.cornerRadius = 45
        avatarImageView.clipsToBounds = true
    }
    
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        guard let avatarImage = WBUserAccount.userAccount?.avatar_large else {
            return
        }
        ///设置
        let url = URL.init(string: avatarImage)
        avatarImageView.sd_setImage(with: url)
        startAnimation()
    }
    
    private func startAnimation(){
        self.avatarBottomCons.constant = UIScreen.main.bounds.size.height - 160
        UIView.animate(withDuration: 2.0, animations: { 
            self.view.layoutIfNeeded()
            }) { (true) in
                UIView.animate(withDuration: 1.5, animations: {
                    
                    self.welComeLabel.alpha = 1.0
                    }, completion: { (true) in
                        NotificationCenter.default.post(name: NSNotification.Name.init(WBSwitchRootViewController), object: true)
                })
        }
        
      
    }

}
